﻿using Dal;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bll
{
    public class RoleBll
    {
        public int Add(TRole model)
        {
            using (var db = new BabyfaceEntities())
            {
                var dal = new RoleDal(db);
                return dal.Add(model);
            }
        }

        public int Edit(TRole model)
        {
            using (var db = new BabyfaceEntities())
            {
                var dal = new RoleDal(db);
                return dal.Edit(model);
            }
        }

        public int Delete(int id)
        {
            using (var db = new BabyfaceEntities())
            {
                var dal = new RoleDal(db);
                return dal.Delete(id);
            }
        }

        public TRole GetById(int id)
        {
            using (var db = new BabyfaceEntities())
            {
                var dal = new RoleDal(db);
                return dal.GetById(id);
            }
        }

        public IList<TRole> GetAll()
        {
            using (var db = new BabyfaceEntities())
            {
                var dal = new RoleDal(db);
                var list = dal.GetAll();
                return list;
            }
        }
    }
}
